<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台（PHP版）
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码，建议反馈是我们前进的动力
// | 开源版本可自由商用，可去除界面版权logo
// | gitee下载：https://gitee.com/likeshop_gitee/likeadmin
// | github下载：https://github.com/likeshop-github/likeadmin
// | 访问官网：https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------

namespace app\common\command;


use app\common\model\book\Bookread;
use app\common\model\bookdata\Bookdata;
use app\common\model\buy\EgoldLog as EgoldLogModel;
use app\common\model\callback\OrderCallback;
use app\common\model\order\Order;
use app\common\model\promotion\PromotionLink;
use app\common\model\read_uv\ReadUv;
use app\common\model\user\User;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\facade\Log;


class SyncIsNewUser extends Command
{
    protected function configure()
    {
        $this->setName('sync_is_new_user')
            ->setDescription('重置为老用户');
    }


    protected function execute(Input $input, Output $output)
    {
        try {
            $date = date('Y-m-d',time());
            $start_time = strtotime($date);
//            $end_time = strtotime($date)+86400;
            $user_id_arr = User::where('create_time','<',$start_time)->where('is_new_user',0)->column('id');
            User::where('id','in',$user_id_arr)->update(['is_new_user'=>1]);
            $output->writeln('sync_is_new_user');
            return true;
        } catch (\Exception $e) {
            Log::write('失败,失败原因:' . $e->getMessage());
            return false;
        }
    }

}